package com.hospital.doctor.config;

import com.hospital.doctor.interceptor.JWTInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author QIUYANG
 * @title: InterceptorConfig
 * @description: TODO
 * @date 2021/5/613:57
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/doctor/**")
                .addPathPatterns("/bingli/**")
                .addPathPatterns("/check/**")
                .addPathPatterns("/checktable/**")
                .addPathPatterns("/drug/**")
                .addPathPatterns("/medical/**")
                .addPathPatterns("/operation/**")
                .addPathPatterns("/patient/**")
                .addPathPatterns("/prescription/**")
                .addPathPatterns("/round/**")
                .addPathPatterns("/login/test")
//                .addPathPatterns("/**")、
                .excludePathPatterns("/login/do")
                .excludePathPatterns("/check/download/**")
                .excludePathPatterns("/medical/download/**")
                .excludePathPatterns("/prescription/download/**");

    }

//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        registry.addMapping("/**")
//                .allowedHeaders("*")
//                .allowedOrigins("*")
//                .allowedOriginPatterns("*")
//                .allowCredentials(true)
//                .allowedMethods("GET","POST","PUT","DELETE")
//                .maxAge(3600);
//    }
    //
}
